package testing;

import static org.junit.Assert.*;

import java.util.Iterator;

import solutions.ThreadedBST;

import org.junit.Test;

public class ThreadedBSTTests {

	@Test
	public void testHeight() {
		ThreadedBST<Integer> tree = new ThreadedBST<Integer>();
		assertTrue(tree.height() == 0);
		tree.insert(12);
		tree.insert(13);
		assertTrue(tree.height() == 2);
	}

	@Test
	public void testInsert1() {
		ThreadedBST<Integer> tree = new ThreadedBST<Integer>();
		tree.insert(5);
		assertTrue(tree.find(5));
		assertFalse(tree.find(3));
		assertTrue(tree.height() == 1);
	}
	
	@Test
	public void testIterator0() {
		ThreadedBST<Integer> tree = new ThreadedBST<Integer>();
		assertTrue(tree.height() == 0);
		
		Iterator<Integer> it = tree.inorderTraversal();
		while(it.hasNext()) {
			System.out.println(it.next().toString() + " ");
		}
	}
	@Test
	public void testIterator1() {
		ThreadedBST<Integer> tree = new ThreadedBST<Integer>();
		tree.insert(5);
		tree.insert(4);
		tree.insert(13);
		tree.insert(1);
		tree.insert(18);
		tree.insert(14);
		assertTrue(tree.height() == 4);
		assertTrue(tree.size() == 6);
		
		Iterator<Integer> it = tree.inorderTraversal();
		while(it.hasNext()) {
			System.out.println(it.next().toString() + " ");
		}
	}
}
